let path = require('path');
let HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
    mode: 'development',
    entry: {
        lazy: './src/lazy.js',
    },
    output: {
        filename: '[name].js',
        path: path.resolve('dist')
    },
    devServer: {
        contentBase: 'dist',
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        presets: ['@babel/preset-env'],
                        plugins: [
                            // 用来实现路由懒加载
                            '@babel/plugin-syntax-dynamic-import'
                        ]
                    }
                } 
            }
        ]
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: './public/index.html',
            filename: 'index.html'
        }),
    ]
}